package com.personal.site.utils;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class Result<T>{
    private boolean success;

    private Integer code;
    private T result;
    private String msg;

    public static <T>Result<T> OK (Integer code,T data,String msg){
        return new Result<>(true,code,data,msg);
    }

    public static <T>Result<T> OK (T data,String msg){
        return Result.OK(200,data,msg);
    }

    public static <T>Result<T> OK (T data){
        return Result.OK(200,data,"成功！");
    }

    public static <T>Result<T> error(Integer code,T data,String msg){
        return new Result<>(true,code,data,msg);
    }

    public static <T>Result<T> error(T data,String msg){
        return Result.error(500,data,msg);
    }

    public static <T>Result<T> error(String msg){
        return new Result<>(true,500,null,msg);
    }




}
